<%--
  Created by IntelliJ IDEA.
  User: 18785
  Date: 2024/12/16
  Time: 下午6:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改车票信息</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }
        header {
            background-color: #007bff;
            color: white;
            text-align: center;
            padding: 1rem;
        }
        main {
            flex-grow: 1;
            padding: 2rem;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        form {
            background-color: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 500px;
        }
        h2 {
            text-align: center;
            margin-bottom: 1rem;
        }
        label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: bold;
        }
        input[type="text"], input[type="date"], input[type="time"], input[type="number"], select {
            width: 100%;
            padding: 0.5rem;
            margin-bottom: 1rem;
            border: 1px solid #ced4da;
            border-radius: 4px;
        }
        input[type="hidden"] {
            display: none;
        }
        input[type="checkbox"] {
            margin-right: 0.5rem;
        }
        .form-group {
            margin-bottom: 1rem;
        }
        .submit-btn {
            background-color: #28a745;
            color: white;
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            display: block;
            margin: 1rem auto 0;
            width: fit-content;
        }
        .submit-btn:hover {
            background-color: #218838;
        }
        a.back-link {
            display: block;
            text-align: center;
            margin-top: 1rem;
            color: #007bff;
            text-decoration: none;
            font-size: 1rem;
        }
        footer {
            text-align: center;
            padding: 1rem;
            background-color: #007bff;
            color: white;
            margin-top: auto;
        }
    </style>
</head>
<body>
<header>
    <h1>车票管理系统</h1>
</header>
<main>
    <form action="edit-ticket" method="post">
        <h2>修改车票信息</h2>
        <c:set var="ticket" value="${requestScope.ticket}" />
        <input type="hidden" name="id" value="${ticket.id}">
        <div class="form-group">
            <label for="type">行程:</label>
            <input type="text" id="type" name="type" value="${ticket.type}" required>
        </div>
        <div class="form-group">
            <label for="ticketType">车票类型:</label>
            <select id="ticketType" name="ticketType" required>
                <option value="Car" ${ticket.ticketType == 'Car' ? 'selected' : ''}>汽车</option>
                <option value="Plane" ${ticket.ticketType == 'Plane' ? 'selected' : ''}>飞机</option>
                <option value="Train" ${ticket.ticketType == 'Train' ? 'selected' : ''}>火车</option>
                <option value="Ship" ${ticket.ticketType == 'Ship' ? 'selected' : ''}>船</option>
            </select>
        </div>
        <div class="form-group">
            <label for="departureCity">始发地:</label>
            <input type="text" id="departureCity" name="departureCity" value="${ticket.departureCity}" required>
        </div>
        <div class="form-group">
            <label for="arrivalCity">目的地:</label>
            <input type="text" id="arrivalCity" name="arrivalCity" value="${ticket.arrivalCity}" required>
        </div>
        <div class="form-group">
            <label for="departureDate">出发日期:</label>
            <input type="date" id="departureDate" name="departureDate" value="${ticket.departureDate}" required>
        </div>
        <div class="form-group">
            <label for="startTime">发车时间:</label>
            <input type="time" id="startTime" name="startTime" value="${ticket.startTime}" required>
        </div>
        <div class="form-group">
            <label for="endTime">到达时间:</label>
            <input type="time" id="endTime" name="endTime" value="${ticket.endTime}" required>
        </div>
        <div class="form-group">
            <label for="price">车票价格:</label>
            <input type="number" id="price" step="0.01" name="price" value="${ticket.price}" required>
        </div>
        <div class="form-group">
            <label>
                <input type="checkbox" name="hasInfantOption" ${ticket.hasInfantOption ? 'checked' : ''}>
                是否携带婴儿
            </label>
            <label>
                <input type="checkbox" name="hasChildOption" ${ticket.hasChildOption ? 'checked' : ''}>
                是否携带儿童
            </label>
        </div>
        <button type="submit" class="submit-btn">更新</button>
    </form>
    <a href="view-tickets" class="back-link">返回车票管理</a>
</main>
<footer>
    <p>&copy; 2024 订票管理平台</p>
</footer>
</body>
</html>
